from peewee import BigAutoField, CharField
from common.model.abstrct import AbstractModel, IntEnumField
from enums.permission_enum import PermissionTypeEnum, PermissionStatusEnum


class TotalPermission(AbstractModel):
    class Meta:
        table_name = "tb_permission"

    permission_id = BigAutoField(primary_key=True)
    name = CharField(max_length=16, help_text="权限的名字")
    permission_type = IntEnumField(help_text="权限的类型", choices=PermissionTypeEnum)
    # path和interface一起使用 主要是对于path中有参数不好判断 还要考虑考虑
    path = CharField(max_length=128, help_text="接口的路径,当permission_type=2时有效", null=True)
    interface = CharField(max_length=128, help_text="接口唯一标识,当permission_type=2时有效", null=True)
    button = CharField(max_length=128, help_text="按钮唯一标识,当permission_type=1时有效", null=True)
    status = IntEnumField(choices=PermissionStatusEnum, help_text="权限状态", default=PermissionStatusEnum.enable)